package com.momoauth.api_client.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.momoauth.api_client.entity.Organization;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrganizationMapper extends BaseMapper<Organization> {

    /**
     * 组织列表
     * @param page
     * @param wrapper
     * @return
     */
    @Select("SELECT orgId,orgName,createTime,status FROM organization ${ew.customSqlSegment}")
    List<Organization> getOrganizationList(Page<Organization> page, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    /**
     * 删除组织
     * @param orgId
     * @return
     */
    @Update("UPDATE organization SET isDelete = 1 WHERE orgId = #{orgId}")
    Integer deleteOrganizationById(Long orgId);
}
